import request from '@/utils/request';
import qs from "qs";

export async function purchaseList(params) {
  const limit = params.pageSize;
  const page = params.current;
  const my_params = {
    limit: limit,
    page: page
  };
  Object.assign(params, my_params);
  delete params.current;
  delete params.pageSize;

  return request('/supplyChain/product/page', {
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}


export async function getPurchaseDetail(params) {
  return request(`/supplyChain/product/detail`, {
    params
  });
}

export async function orderOut(data) {
  return request('supplyChain/oldSale/orderOut', {
    method: 'POST',
    data
  });
}

export async function exportPrinter(params) {
  return request(`/supplyChain/oldSale/printer`, {
    method: 'GET',
    responseType: 'blob',
    params:params,
    paramsSerializer: params => {
      return qs.stringify(params, { indices: false })
    }
  });
}

export async function doInStock(data) {
  return request('supplyChain/stuff/doInStock', {
    method: 'POST',
    data
  });
}

export async function getPayFiles(params) {
  return request(`/supplyChain/oldSale/getPayFiles`, {
    params
  });
}

export async function delPayFile(data) {
  return request(`/supplyChain/purchase/delFile`, {
    method: 'POST',
    data
  });
}
